from d4.models import D4Dic
from django_filters import rest_framework as filters


class DicFilter(filters.FilterSet):
    """字典表"""

    # s_id = filters.CharFilter(field_name='id', lookup_expr='icontains')
    # s_fid = filters.CharFilter(field_name='fid', lookup_expr='icontains')
    s_name = filters.CharFilter(field_name="name", lookup_expr="icontains")
    s_value = filters.CharFilter(field_name="value", lookup_expr="icontains")
    s_code = filters.CharFilter(field_name="code", lookup_expr="icontains")
    # s_description = filters.CharFilter(field_name='description', lookup_expr='icontains')
    # s_is_locked = filters.CharFilter(field_name='is_locked', lookup_expr='icontains')
    # s_is_delete = filters.CharFilter(field_name='is_delete', lookup_expr='icontains')
    # s_sort = filters.NumberFilter(field_name='sort', lookup_expr='icontains')
    # s_created_by = filters.CharFilter(field_name='created_by', lookup_expr='icontains')
    # s_created_date = filters.DateTimeFilter(field_name='created_date', lookup_expr='icontains')
    # s_update_by = filters.CharFilter(field_name='update_by', lookup_expr='icontains')
    # s_update_date = filters.DateTimeFromToRangeFilter(field_name='update_date', lookup_expr='icontains')
    # s_type = filters.CharFilter(field_name='type', lookup_expr='icontains')
    # s_status = filters.CharFilter(field_name='status', lookup_expr='icontains')

    class Meta:
        # 模型类名
        model = D4Dic
        # 可以过滤的字段
        fields = ["name", "code"]
        # 如果不想要精准匹配
        # fields = []

# class DicFilter(filters.FilterSet):
#     """字典表"""

#     s_value = filters.CharFilter(field_name="value", lookup_expr="icontains")

#     class Meta:
#         # 模型类名
#         model = D4Dic
#         # 放到字典中
#         fields = {"name": ["exact", "icontains"], "code": ["exact", "gte", "lte"]}
